package cn.weihuachao;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class Main {
    public static void main(String[] args) throws InterruptedException, BrokenBarrierException {
        Object o = new Object();
        new Thread(() ->{
            try {
                synchronized (o){
                    o.wait();
                }
                System.out.println("a");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(() ->{
            try {
                synchronized (o){
                    o.wait();
                }
                System.out.println("b");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        Thread.sleep(1000L);
        synchronized (o){
            o.notifyAll();
        }
    }
}
